import React, { Component } from 'react';
import { HomeDiv } from './style'

// import { renderRoutes } from 'react-router-config';
import { connect } from 'react-redux'
import { setHomeListData } from '@/store/action/home'

// 头部搜索框
import SearchNav from '@/components/SearchNav'
import Swiper from '@/components/Swiper'
// 搜索框右侧图片
import person from '../../assets/images/person.png';

import List1 from './ui/List1';
import List2 from './ui/List2';
import HotActive from './ui/HotActive';
import ListView from './ui/ListView';



@connect(state => ({ homeListData: state.getIn(['home', 'homeListData']).toJS() }), { setHomeListData })

class index extends Component {

  state = {
    // 搜索框placeholder
    context: '搜索商品,品牌',
    // 搜索框右侧有无东西
    isShowProfile: true,
    // 搜索框右侧图片
    person
  }


  componentDidMount() {
    this.props.setHomeListData()
  }

  changeSubRouter() {
    let type = 999;
    switch (this.props.location.pathname) {
      case '/home/tuijian':
        type = 999;
        break;
      case '/home/lanqiu':
        type = 1;
        break;
      case '/home/paobu':
        type = 2;
        break;
      case '/home/jianshen':
        type = 3;
        break;
      case '/home/chaoliu':
        type = 4;
        break;

      default:
        break;
    }
    return type;
  }




  render() {

    // console.log(this.props)

    return (
      <HomeDiv className="page">
        <header>
          {/* 搜索框 */}
          <SearchNav {...this.state} />
        </header>

        {/* 轮播图 */}
        <Swiper />

        <List1 />
        <List2 />

        {/* 热门活动 */}
        <HotActive />

        {/* ListView 长列表*/}
        <ListView />

      </HomeDiv>
    );
  }
}

export default index;
